import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_demo/chapter13-Internationalization/language/LocalizationsResource.dart';

class ProxyLocalizations extends LocalizationsDelegate<LocalizationsResource> {


  @override
  bool isSupported(Locale locale) {
    return ['en', 'zh'].contains(locale.languageCode);
  }

  @override
  Future<LocalizationsResource> load(Locale locale) {
    print('$locale');
    return SynchronousFuture<LocalizationsResource>(
      LocalizationsResource(locale.languageCode == 'zh')
    );
  }

  @override
  bool shouldReload(LocalizationsDelegate<LocalizationsResource> old) => false;

}